<!-- 我的优惠券 -->
<template>
  <div class="coupons">
    <div class="cou-side">
      <div
        class="sides"
        v-for="(item,index) in items"
        :key="index"
        @click="navigation(index)"
        :class="{'action':leftcolor==index}"
      >
        <span>{{item.title}}</span>
      </div>
    </div>
    <div v-show="unused">未使用</div>
    <div v-show="haused">已使用</div>
    <div v-show="vouche">兑换券</div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      unused: true,
      haused: false,
      vouche: false,
      leftcolor: 0, // 导航栏下标
      items: [{ title: "未使用" }, { title: "已使用" }, { title: "兑换券" }]
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    navigation(index) {
      this.leftcolor = index;
      if (index == 0) {
        this.unused = true;
        this.haused = false;
        this.vouche = false;
      } else if (index == 1) {
        this.unused = false;
        this.haused = true;
        this.vouche = false;
      } else if (index == 2) {
        this.unused = false;
        this.haused = false;
        this.vouche = true;
      }
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style scoped>
.cou-side {
  width: 80%;
  height: 80rpx;
  margin-left: 10%;
  margin-top: 40rpx;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1rpx solid #ff634e;
  border-radius: 40rpx;
}
.sides {
  text-align: center;
  line-height: 80rpx;
  flex: 0.3333;
  color: #a7a7a7;
}
.sides > span {
  font-size: 32rpx;
}
.sides:first-child {
  border-top-left-radius: 38rpx;
  border-bottom-left-radius: 38rpx;
}
.sides:last-child {
  border-top-right-radius: 38rpx;
  border-bottom-right-radius: 38rpx;
}
.action {
  background-color: #ff634e;
  color: #ffffff;
}
</style>